<?php
namespace backend\models\activeRecords;

use common\models\User;
use Yii;
use yii\db\ActiveRecord;

/**
 * This is the model class for table "{{%statistics_day}}".
 *
 * @property string $id 自增id
 * @property int $reg_num 注册人数
 * @property string $pay_sum 充值总额
 * @property int $pay_num 充值人数
 * @property string $pay_rate 充值率
 * @property string $arppu arppu
 * @property string $next_remains 次日留存
 * @property string $third_remains 3日留存
 * @property string $seven_remains 7日留存
 * @property string $thirty_remains 30日留存
 * @property string $game_name 游戏名称
 * @property string $server_name 区服
 * @property string $guild_sign 公会标识
 * @property string $spread_key_2 推广员标识
 * @property int $record_time 最后记录时间(根据用户表)
 * @property string $date 日期
 */
class StatisticsDay extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%statistics_day}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['reg_num', 'pay_num', 'record_time'], 'integer'],
            [['pay_sum', 'pay_rate', 'arppu', 'next_remains', 'third_remains', 'seven_remains', 'thirty_remains'], 'number'],
            [['game_name', 'server_name'], 'string', 'max' => 255],
            [['guild_sign','spread_key_2'], 'string', 'max' => 20],
            [['date'], 'string', 'max' => 32],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', '自增id'),
            'reg_num' => Yii::t('app', '注册人数'),
            'pay_sum' => Yii::t('app', '充值总额'),
            'pay_num' => Yii::t('app', '充值人数'),
            'pay_rate' => Yii::t('app', '充值率%'),
            'arppu' => Yii::t('app', 'arppu'),
            'next_remains' => Yii::t('app', '次日留存'),
            'third_remains' => Yii::t('app', '3日留存'),
            'seven_remains' => Yii::t('app', '7日留存'),
            'thirty_remains' => Yii::t('app', '30日留存'),
            'game_name' => Yii::t('app', '游戏名称'),
            'server_name' => Yii::t('app', '区服'),
            'guild_sign' => Yii::t('app', '公会标识'),
            'spread_key_2' => Yii::t('app', '推广员标识'),
            'record_time' => Yii::t('app', '最后记录时间(根据用户表)'),
            'date' => Yii::t('app', '日期'),
        ];
    }

    public function getGuild(){
        return $this->hasOne(Guild::className(),['guild_sign'=>'guild_sign']);
    }

    public function getUser(){
        return $this->hasOne(User::className(),['position'=>'spread_key_2']);
    }

}
